package com.hunk.core.entity;

import org.hibernate.annotations.GenericGenerator;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;

/**
 * 
 * @Author Dylan
 * @Project shpam
 * @Version V1.0
 * @Date 2011-6-8 下午04:31:10
 */
@MappedSuperclass
public abstract class UUIDEntity implements IdEntity<String> {
	private static final long serialVersionUID = 3860736774425354405L;
	@Id
	@GeneratedValue(generator = "system-uuid")
	@GenericGenerator(name = "system-uuid", strategy = "uuid")
	@Column(length = 32)
	protected String id;

	@Override
	public String getId() {
		return id;
	}

	@Override
	public void setId(String id) {
        if (null == id) {
            this.id = id;
        } else {
            this.id = id.trim().equals("") ? null : id;
        }
    }

}
